Imports CapaDeDatos
Public Class nProveedor
    Private Proveedor As dProveedor = New dProveedor()
    Private Localidad As CapaDeDatos.dLocalidad = New CapaDeDatos.dLocalidad
    Private Condicion As CapaDeDatos.dCondicion = New CapaDeDatos.dCondicion
    Public Function Listar(ByVal CodigoProveedor As String, _
                                    ByVal RazonSocial As String, _
                                    ByVal Cuit As String, _
                                    ByVal Direccion As String, _
                                    ByVal TelCel As String, _
                                    ByVal Mail As String, _
                                    ByVal CondicionCompra As String, _
                                    ByVal CodigoLocalidad As String) As DataSet
        Dim DtsProveedor As DataSet
        DtsProveedor = Proveedor.BuscarFiltrado(CodigoProveedor, _
                                        RazonSocial, _
                                        Cuit, _
                                        Direccion, _
                                        TelCel, _
                                        Mail, _
                                        "", _
                                        CondicionCompra, _
                                        CodigoLocalidad)


        DtsProveedor.Tables(0).Columns.Add("Nombre")
        DtsProveedor.Tables(0).Columns.Add("Descripcion")
        Dim I As Integer

        For I = 0 To DtsProveedor.Tables(0).Rows.Count - 1
            Try
                DtsProveedor.Tables(0).Rows(I)("Nombre") = Localidad.ListarNombres(DtsProveedor.Tables(0).Rows(I)("CodigoLocalidad").ToString(), "").Tables(0).Rows(0)("Nombre").ToString()
            Catch ex As Exception
                DtsProveedor.Tables(0).Rows(I)("Nombre") = "Nombre No Registrado"
            End Try
            Try
                DtsProveedor.Tables(0).Rows(I)("Descripcion") = Condicion.ListarNombres(DtsProveedor.Tables(0).Rows(I)("CondicionCompra").ToString(), "").Tables(0).Rows(0)("Descripcion").ToString()
            Catch ex As Exception
                DtsProveedor.Tables(0).Rows(I)("Descripcion") = "Condicion =" & DtsProveedor.Tables(0).Rows(I)("CondicionCompra").ToString() & " Dias no registrada"
            End Try
        Next

        Return DtsProveedor
    End Function
    Public Function Insertar(ByVal RazonSocial As String, _
                            ByVal Cuit As String, _
                            ByVal Direccion As String, _
                            ByVal TelCel As String, _
                            ByVal Mail As String, _
                            ByVal Estado As String, _
                            ByVal CondicionCompra As String, _
                            ByVal CodigoLocalidad As String, _
                            ByVal CodigoCategoria As String) As Boolean
        Proveedor.Insertar(RazonSocial, _
                        Cuit, _
                        Direccion, _
                        TelCel, _
                        Mail, _
                        Estado, _
                        CondicionCompra, _
                        CodigoLocalidad)
    End Function
    Public Function Eliminar(ByVal CodigoProveedor As String) As Boolean
        Return Proveedor.Eliminar(CodigoProveedor)
    End Function
    Public Function Modificar(ByVal CodigoProv As String, _
                            ByVal RazonSocial As String, _
                            ByVal CUIT As String, _
                            ByVal Direccion As String, _
                            ByVal TelCel As String, _
                            ByVal Mail As String, _
                            ByVal Estado As String, _
                            ByVal CondicionCompra As String, _
                            ByVal CodigoLocalidad As String) As Boolean
        Return Proveedor.Modificar(CodigoProv, _
                                    RazonSocial, _
                                    CUIT, _
                                    Direccion, _
                                    TelCel, _
                                    Mail, _
                                    Estado, _
                                    CondicionCompra, _
                                    CodigoLocalidad)
    End Function
    Public Function DarRazonSocial(ByVal CodigoProveedor As String) As String
        Return Proveedor.BuscarRazon(CodigoProveedor)
    End Function
    Public Function Existe(ByVal Cuit As String) As Boolean
        Return Proveedor.Existe(Cuit)
    End Function

End Class

